package com.ydgk.servlet;

import com.alibaba.fastjson.JSON;
import com.ydgk.bean.Book;
import com.ydgk.dao.BookDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ShowBookServlet", urlPatterns = "/ShowBookServlet.action")
public class ShowBookServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String sid = request.getParameter("sid");

        BookDao bookDao = new BookDao() ;
        List<Book> bookList = bookDao.findByFkId(Integer.parseInt(sid));

        String str= JSON.toJSONString(bookList);

        response.getWriter().print(str);

    }


}
